<template>
  <searh-comp @searchHandle="search" />
  <!-- 内容区域 -->
  <van-list v-if="assShow" finished-text="没有更多了" :finished="loadState" @load="onLoad">
    <div v-for="item in num.list.length" :key="item" class="list">
      <div class="order flexC">{{ item }}</div>
      <div class="article">
        <!-- 标题 -->
        <div class="title"> 标题 </div>
        <!-- 内容 -->
        <div class="detail"> 内容 </div>
        <!-- 作者 -->
        <div class="info">
          <div class="author">
            <SvgIcon name="email" :size="15" />
            沐歌
          </div>
          <div class="time">
            <SvgIcon name="email" :size="15" />
            2012/12/16
          </div>
          <div class="visited">
            <SvgIcon name="email" :size="15" />
            999+
          </div>
        </div>
      </div>
    </div>
  </van-list>
  <div v-else class="association">
    <van-list finished-text="没有更多了" :finished="loadState" @load="onLoad">
      <div v-for="item in 20" class="ass-list">
        <span class="order">12</span>
        <div class="title">F发打发斯蒂芬第三方第三方付</div>
      </div>
    </van-list>
  </div>
</template>

<script lang="ts" setup>
  import { ref, reactive } from 'vue'
  import SearhComp from '@comp/SearchNav/SearchNav.vue'
  const num = reactive({ list: [1, 2, 3, 4, 5] })
  const loadState = ref<boolean>(false)
  const assShow = ref<boolean>(false) //联想输入显隐藏控制
  // 上拉
  const onLoad = () => {
    console.log('lower')
    // setTimeout(() => {
    num.list.push(...[1, 2, 3, 5, 6])
    // }, 200)
    if (num.list.length > 20) {
      setTimeout(() => {
        loadState.value = true
      }, 200)
    }
  }
  // 搜索
  const search = (value: string) => {
    console.log(value, 'vvvv')
  }
</script>
<style lang="scss" scoped>
  .list {
    display: flex;
    padding: 10px;
    border-bottom: 1px groove #fd8c84;
    border-radius: 8px;

    .order {
      border: 1px solid transparent;
      background-color: #fd8c84;
      color: #fffdef;
      padding: 2px 5px;
      margin-right: 10px;
      max-height: 12.5px;
    }

    .article {
      width: 100%;

      .title {
        display: flex;
        padding-right: 20px;
        width: 97%;
        font-size: $blog-text-size;
        color: $nav-bar-title-color;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }

      .detail {
        flex: 1;
        margin-top: $nav-bar-marginTop;
        margin-bottom: $nav-bar-marginTop;
        font-size: $blog-text-size;
        color: $nav-bar-detail-color;
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-all;
        background-color: red;
      }

      .info {
        display: flex;
        font-size: 15px;
        margin-top: $nav-bar-marginTop;
        color: $nav-bar-detail-color;

        .time,
        .author,
        .visited {
          margin-right: 20px;
        }
      }
    }
  }

  .association {
    position: fixed;
    top: $nav-height;
    height: calc(100vh - #{$nav-height});
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(94, 184, 109, 0.3);
    padding: 10px;
    overflow: auto;

    .ass-list {
      display: flex;
      align-items: center;
      border-bottom: 1px dotted $mune-border-color;
      padding: 10px 0;
      margin-bottom: 10px;

      .order {
        border: 1px solid transparent;
        background-color: #fd8c84;
        color: #fffdef;
        padding: 2px 5px;
        margin-right: 10px;
        max-height: 12.5px;
      }

      .title {
      }
    }
  }
</style>
